<?php 

class Discount extends DiscountCore
{

	public function getValue($nb_discounts = 0, $order_total_products = 0, $shipping_fees = 0, $idCart = false, $useTax = true)
	{
		if(class_exists("Vs_FbLogin") && $this->id == Vs_FbLogin::DISCOUNT_ID ) {
			$cart = new Cart((int)($idCart));
			$products = $cart->getProducts();
			$maxPrice = 0;
			$include_tax = true;
			foreach($products as $pr) {
				$price = $include_tax ? $pr['total_wt'] : $pr['total'];
				if($price > $maxPrice) {
					$maxPrice = $price;
				}
			}

			$value = ($maxPrice / 2);
			//die($value);
		}
		else {
			$value = parent::getValue($nb_discounts, $order_total_products, $shipping_fees, $idCart, $useTax);
		}

		return $value;
	}

};